package cn.lyjuan.android.demofive.ui.translate;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import cn.lyjuan.android.demofive.R;

/**
 * Created by chad on 25/10/2017.
 * 两个activity中的 view 的transitionName要跟这里在的 一致
 */

public class SceneStartActivity extends AppCompatActivity
{
    private View imageView;
    private View textView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.ui_compat_sence_start);

        imageView = this.findViewById(R.id.image);
        textView = this.findViewById(R.id.text);
    }

    public void translate(View v)
    {
        Pair<View, String> imagePair = Pair.create(imageView, getResources().getString(R.string.transition_image));
        Pair<View, String> textPair = Pair.create(textView, getResources().getString(R.string.transition_text));

        ActivityOptionsCompat compat = ActivityOptionsCompat.makeSceneTransitionAnimation(this, imagePair, textPair);

        // 单个元素互动
//        ActivityOptionsCompat compat = ActivityOptionsCompat.makeSceneTransitionAnimation(this, v, "abcdef");

        ActivityCompat.startActivity(this, new Intent(this, SceneTargetActivity.class), compat.toBundle());
    }
}
